<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="vtc" uri="/vtc-core-tags"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<html>
<head>
	<title>Data Import</title>
	
	<script type="text/javascript">
	
		$(document).ready(function() {
			$("#mainForm").validate();
		});
	
		function clickBtn(action){
			switch(action){
			case "search":
				  $("#mainForm_search").attr("value", "true");
				  break;
			case "clear":
				  $("#mainForm_search").attr("value", "false");
				  break;
			case "create":
				  $("#mainForm").attr("action", "dataimport!input.action");
				  break;
			}
			
			$("#mainForm").submit();
		}
	</script>
</head>
<body>

<div class="content">  
  <div class="pageTitle">Data Import</div>
  
  <div class="form1">
  <s:form id="mainForm" name="mainForm" action="dataimport.action" method="post">
  	<s:hidden name="search"></s:hidden>
    <table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="sep" ><img src="../images/spacer.gif" style="width:180px;" /></td>
        <td class="sep" ><img src="../images/spacer.gif" style="width:180px;" /></td>
        <td class="sep" ><img src="../images/spacer.gif" style="width:180px;" /></td>
        <td class="sep sep2" ><img src="../images/spacer.gif" /></td>
      </tr>
      <tr>
        <td><label class="fLabel" >Import Job Name </label>
          <div class="fField">
            <s:textfield name="dataimport.jobName" cssStyle="width:150px" cssClass="inputText"/>
          </div></td>
        <td><label class="fLabel" >Interface Type</label>
          <div class="fField">
            <s:select cssClass="inputSelect" cssStyle="width:155px" name="dataimport.interfaceType" 
            		  list="getInterfaceTypeList()" listKey="key" listValue="value"
            		  headerKey="" headerValue="-- All --">
            </s:select>
          </div></td>
          <td><label class="fLabel" >Status </label>
          <div class="fField">
            <s:select cssClass="inputSelect" cssStyle="width:155px" name="dataimport.status" 
            		  list="getStatusList()" listKey="key" listValue="value"
            		  headerKey="" headerValue="-- All --">
            </s:select> 
          </div></td>
      </tr>
        </table>
        
	    <div class="btnSet btnSetTypeB">
		      <div class="left" >
		        <div class="button" >
		          <div class="left" >
		            <div class="right" >
		              <input class="inputButton" type="button" id="searchBtn" name="search" value="Search" onclick="clickBtn('search');"/>
		            </div>
		          </div>
		        </div>
		        
		        <div class="button" >
		          <div class="left" >
		            <div class="right" >
		              <input class="inputButton" type="button" id="clearBtn" name="clear" value="Clear" onclick="clickBtn('clear');"/>
		            </div>
		          </div>
		        </div>
		        
		        <div class="button" >
		          <div class="left" >
		            <div class="right" >
		              <input class="inputButton" type="button" id="createBtn" name="create" value="Create" onclick="clickBtn('create')"/>
		            </div>
		          </div>
		        </div>
		        
	      </div>
      	</div>
    
		<s:if test="%{page!=null&&page.result!=null&&page.result.size()!=0}">
		<div class="sListBorder">
		   <div class="sList">
		     <table width="100%" cellspacing="0" cellpadding="0" border="0" class="sTable">
		       <tbody><tr>
		         <td style="width: 70px;" class="sTh t">Import Job Name </td>
		         <td class="sTh t">Interface Type </td>
		         <td class="sTh t">Run At</td>
		         <td class="sTh t">Completion Time</td>
		         <td class="sTh t">Status</td>
		       </tr>
		       <s:iterator value="page.result" var="dataimport" status="st">
		       
		      	  <s:set var="trClass" value="'sRow1'"></s:set>
		    	  <s:if test="#st.index%2==0">
		       	 		<s:set var="trClass" value="'sRow2'"></s:set>
			       	 <s:else>
			       	    <s:set var="trClass" value="'sRow1'"></s:set>
			       	 </s:else>
				  </s:if>
				  
			      <tr class="<s:property value='#trClass'/>">
			         <td class="sCell"><a href="dataimport!input.action?dataimportId=<s:property value='#dataimport.id'/>"><s:property value="#dataimport.jobName" default="&nbsp;" escape="false"/></a></td>
			         <td class="sCell"><s:property value="getInterfaceTypeName(#dataimport.interfaceType)" default="&nbsp;" escape="false"/></td>
			         <td class="sCell"><s:date name="#dataimport.runAt" format="dd/MM/yyyy HH:mm" />&nbsp;</td>
			         <td class="sCell"><s:date name="#dataimport.completionTime" format="dd/MM/yyyy HH:mm" />&nbsp;</td>
			         <td class="sCell"><s:property value="#dataimport.status" default="&nbsp;" escape="false"/></td>
		      	 </tr>
		       </s:iterator>
		     </tbody>
		     </table>
		   </div>
		   
		   <vtc:paging page="%{page}"></vtc:paging>
		 </div>
		</s:if> 
	
	</s:form> 
	</div>

</div>

</body>
</html>